import java.util.HashSet;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-12-02
 * Time:18:29
 */
public class Test {
    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> hash=new HashSet<>();
        for (int i = 0; i < jewels.length(); i++) {
            char ch=jewels.charAt(i);
            hash.add(ch);
        }
        int nums=0;
        for (int i = 0; i < stones.length(); i++) {
            char s=stones.charAt(i);
            if(hash.contains(s)){
                nums++;
            }
        }
        return nums;
    }
    public int singleNumber(int[] nums) {
        HashSet<Integer> hash=new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(hash.contains(nums[i])){
                hash.remove(nums[i]);
            }else {
                hash.add(nums[i]);
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if(hash.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }
}
